package com.xyy.saas.payment.cores.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;

public enum PaySceneEnum {
    ONLINE_PAY("online_pay", "在线支付"),
    OTHER_PAY("other_pay", "他人代付");

    private String code;
    private String desc;

    private static Map<String,PaySceneEnum> code2Enum;

    static {
        code2Enum = Arrays.asList(values()).stream().collect(Collectors.toMap(PaySceneEnum::getCode, UnaryOperator.identity()));
    }

    PaySceneEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static PaySceneEnum getEnum(String code){
        return code2Enum.get(code);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
